home *** CD-ROM | disk | FTP | other *** search
/ Aminet 2 / Aminet AMIGA CDROM (1994)(Walnut Creek)[Feb 1994][W.O. 44790-1].iso / Aminet / comm / term / term34Source.lha / termDial.c < prev    next >
C/C++ Source or Header  |  1993-07-16  |  39KB  |  1,598 lines

  1. /*
  2. **    termDial.c
  3. **
  4. **    The dialing routine as called by the phonebook
  5. **
  6. **    Copyright © 1990-1993 by Olaf `Olsen' Barthel & MXM
  7. **        All Rights Reserved
  8. */
  9.  
  10. #include "termGlobal.h"
  11.  
  12.     /* Panel gadget IDs. */
  13.  
  14. enum    {    GAD_SKIP,GAD_REMOVE,GAD_ONLINE,GAD_ABORT,
  15.         GADGET_COUNT };
  16.  
  17.     /* Panel box IDs. */
  18.  
  19. enum    {    BOX_CALL_COMMENT_NUMBER_NEXT,BOX_TIME_TRY,BOX_MESSAGE,
  20.         BOX_COUNT };
  21.  
  22.     /* CreateAllGadgets():
  23.      *
  24.      *    Create all gadgets required by the dial panel.
  25.      */
  26.  
  27. STATIC struct Gadget *
  28. CreateAllGadgets(struct TextBox **BoxArray,struct TextBox **BoxList,struct Gadget **GadgetArray,struct Gadget **GadgetList)
  29. {
  30.     struct Gadget        *Gadget;
  31.     struct NewGadget     NewGadget;
  32.     UWORD             Counter = 0,BoxCounter = 0;
  33.     struct TextBox        *Box;
  34.  
  35.     memset(&NewGadget,0,sizeof(struct NewGadget));
  36.  
  37.     SZ_SizeSetup(Window -> WScreen,&UserFont,TRUE);
  38.  
  39.     if(Gadget = CreateContext(GadgetList))
  40.     {
  41.         LONG ButtonWidth,LeftEdge;
  42.  
  43.         LeftEdge = SZ_LeftOffsetDelta(MSG_DIALPANEL_CALLING_TXT,MSG_DIALPANEL_MESSAGE_TXT);
  44.  
  45.         SZ_AddLeftOffset(LeftEdge);
  46.  
  47.         SZ_ResetMaxWidth();
  48.  
  49.         SZ_UpdateMaxWidth(BUTTON_KIND,LocaleString(MSG_DIALPANEL_SKIP_GAD),0,NULL);
  50.         SZ_UpdateMaxWidth(BUTTON_KIND,LocaleString(MSG_GLOBAL_REMOVE_GAD),0,NULL);
  51.         SZ_UpdateMaxWidth(BUTTON_KIND,LocaleString(MSG_DIALPANEL_GO_TO_ONLINE_GAD),0,NULL);
  52.         SZ_UpdateMaxWidth(BUTTON_KIND,LocaleString(MSG_GLOBAL_ABORT_GAD),0,NULL);
  53.  
  54.         ButtonWidth = SZ_ResetMaxWidth();
  55.  
  56.         if(ButtonWidth * 4 + 3 * InterWidth > SZ_BoxWidth(45) + LeftEdge)
  57.             SZ_SetWidth(ButtonWidth * 4 + 3 * InterWidth - LeftEdge);
  58.         else
  59.             SZ_SetWidth(SZ_BoxWidth(45));
  60.  
  61.         BoxArray[BoxCounter++] = Box = SZ_CreateTextBox(BoxList,
  62.             SZ_Chars,    45,
  63.             SZ_Lines,    4,
  64.             SZ_AutoWidth,    TRUE,
  65.         TAG_DONE);
  66.  
  67.         SZ_SetBoxTitles(Box,LocaleString(MSG_DIALPANEL_CALLING_TXT),LocaleString(MSG_DIALPANEL_COMMENT_TXT),LocaleString(MSG_DIALPANEL_NUMBER_TXT),LocaleString(MSG_DIALPANEL_NEXT_TXT),NULL);
  68.  
  69.         BoxArray[BoxCounter++] = Box = SZ_CreateTextBox(BoxList,
  70.             SZ_Chars,    45,
  71.             SZ_Lines,    2,
  72.             SZ_AutoWidth,    TRUE,
  73.         TAG_DONE);
  74.  
  75.         SZ_SetBoxTitles(Box,LocaleString(MSG_DIALPANEL_TIMEOUT_TXT),LocaleString(MSG_DIALPANEL_ATTEMPT_TXT),NULL);
  76.  
  77.         BoxArray[BoxCounter] = Box = SZ_CreateTextBox(BoxList,
  78.             SZ_Chars,    45,
  79.             SZ_Lines,    1,
  80.             SZ_AutoWidth,    TRUE,
  81.         TAG_DONE);
  82.  
  83.         SZ_SetBoxTitles(Box,LocaleString(MSG_DIALPANEL_MESSAGE_TXT),NULL);
  84.  
  85.         if(Box)
  86.         {
  87.             NewGadget . ng_GadgetText    = LocaleString(MSG_DIALPANEL_SKIP_GAD);
  88.             NewGadget . ng_GadgetID        = Counter;
  89.  
  90.             SZ_SetWidth(ButtonWidth);
  91.  
  92.             GadgetArray[Counter++] = Gadget = CreateGadget(BUTTON_KIND,Gadget,&NewGadget,
  93.                 SZ_Adjust,    TRUE,
  94.                 SZ_AutoWidth,    TRUE,
  95.                 SZ_AlignExtra,    TRUE,
  96.                 SZ_AlignBottom,    TRUE,
  97.                 SZ_GroupCount,    4,
  98.             TAG_DONE);
  99.  
  100.             NewGadget . ng_GadgetText    = LocaleString(MSG_GLOBAL_REMOVE_GAD);
  101.             NewGadget . ng_GadgetID        = Counter;
  102.  
  103.             GadgetArray[Counter++] = Gadget = CreateGadget(BUTTON_KIND,Gadget,&NewGadget,
  104.                 SZ_Adjust,    TRUE,
  105.                 SZ_AutoWidth,    TRUE,
  106.                 SZ_GroupNext,    TRUE,
  107.             TAG_DONE);
  108.  
  109.             NewGadget . ng_GadgetText    = LocaleString(MSG_DIALPANEL_GO_TO_ONLINE_GAD);
  110.             NewGadget . ng_GadgetID        = Counter;
  111.  
  112.             GadgetArray[Counter++] = Gadget = CreateGadget(BUTTON_KIND,Gadget,&NewGadget,
  113.                 SZ_Adjust,    TRUE,
  114.                 SZ_AutoWidth,    TRUE,
  115.                 SZ_GroupNext,    TRUE,
  116.             TAG_DONE);
  117.  
  118.             NewGadget . ng_GadgetText    = LocaleString(MSG_GLOBAL_ABORT_GAD);
  119.             NewGadget . ng_GadgetID        = Counter;
  120.  
  121.             GadgetArray[Counter] = Gadget = CreateGadget(BUTTON_KIND,Gadget,&NewGadget,
  122.                 SZ_Adjust,    TRUE,
  123.                 SZ_AutoWidth,    TRUE,
  124.                 SZ_GroupNext,    TRUE,
  125.             TAG_DONE);
  126.         }
  127.         else
  128.             return(NULL);
  129.     }
  130.  
  131.     return(Gadget);
  132. }
  133.  
  134.     /* BuildName(STRPTR Name):
  135.      *
  136.      *    Build a file name from a BBS name and the current date.
  137.      */
  138.  
  139. STATIC VOID __regargs
  140. BuildName(STRPTR Name,STRPTR Date)
  141. {
  142.     if(Date[0])
  143.     {
  144.         WORD    NameLen = strlen(Name),
  145.             DateLen = strlen(Date),
  146.             Delta;
  147.  
  148.         if((Delta = NameLen + 1 + DateLen - 32) > 0)
  149.             Name[NameLen - Delta] = 0;
  150.  
  151.         strcat(Name,"_");
  152.         strcat(Name,Date);
  153.     }
  154. }
  155.  
  156.     /* FixName(STRPTR Name):
  157.      *
  158.      *    Build a correct AmigaDOS filename from a BBS name.
  159.      */
  160.  
  161. STATIC VOID __regargs
  162. FixName(STRPTR Name)
  163. {
  164.     WORD    NameLen    = strlen(Name),
  165.         i;
  166.  
  167.         /* Replace special characters. */
  168.  
  169.     for(i = 0 ; i < NameLen ; i++)
  170.     {
  171.         switch(Name[i])
  172.         {
  173.             case ' ':
  174.  
  175.                 Name[i] = '_';
  176.                 break;
  177.  
  178.             case ':':
  179.  
  180.                 Name[i] = '.';
  181.                 break;
  182.  
  183.             case '/':
  184.  
  185.                 Name[i] = '\\';
  186.                 break;
  187.  
  188.             case '\"':
  189.  
  190.                 Name[i] = '\'';
  191.                 break;
  192.         }
  193.     }
  194.  
  195.         /* Truncate the name. */
  196.  
  197.     if(NameLen > 31)
  198.         Name[31] = 0;
  199. }
  200.  
  201.     /* OpenAutoCaptureFile(STRPTR SomeName):
  202.      *
  203.      *    Open a capture file.
  204.      */
  205.  
  206. STATIC VOID __regargs
  207. OpenAutoCaptureFile(STRPTR SomeName)
  208. {
  209.     UBYTE        SharedBuffer[MAX_FILENAME_LENGTH],
  210.             Name[50],
  211.             Date[20],
  212.             Time[20];
  213.     struct DateTime    DateTime;
  214.  
  215.         /* Get the current time and date. */
  216.  
  217.     DateStamp(&DateTime . dat_Stamp);
  218.  
  219.         /* Prepare for date conversion. */
  220.  
  221.     DateTime . dat_Format    = FORMAT_DOS;
  222.     DateTime . dat_Flags    = 0;
  223.     DateTime . dat_StrDay    = NULL;
  224.     DateTime . dat_StrDate    = Date;
  225.     DateTime . dat_StrTime    = Time;
  226.  
  227.         /* Convert the date. */
  228.  
  229.     if(DateToStr(&DateTime))
  230.     {
  231.             /* Remember the BBS name. */
  232.  
  233.         strcpy(Name,SomeName);
  234.  
  235.             /* Append the creation date if necessary. */
  236.  
  237.         if(Config -> CaptureConfig -> AutoCaptureDate == AUTOCAPTURE_DATE_NAME)
  238.             BuildName(Name,Date);
  239.  
  240.             /* Make it a reasonable name. */
  241.  
  242.         FixName(Name);
  243.  
  244.             /* Get the capture file path. */
  245.  
  246.         strcpy(SharedBuffer,Config -> CaptureConfig -> CapturePath);
  247.  
  248.             /* Try to build a valid file and path name. */
  249.  
  250.         if(AddPart(SharedBuffer,Name,MAX_FILENAME_LENGTH))
  251.         {
  252.                 /* Is the capture file still open? */
  253.  
  254.             if(FileCapture)
  255.             {
  256.                     /* Close the file. */
  257.  
  258.                 BufferClose(FileCapture);
  259.  
  260.                     /* Any data written? */
  261.  
  262.                 if(!GetFileSize(CaptureName))
  263.                     DeleteFile(CaptureName);
  264.                 else
  265.                 {
  266.                     AddProtection(CaptureName,FIBF_EXECUTE);
  267.  
  268.                     if(Config -> MiscConfig -> CreateIcons)
  269.                         AddIcon(CaptureName,FILETYPE_TEXT,TRUE);
  270.                 }
  271.             }
  272.  
  273.                 /* Try to append the new data. */
  274.  
  275.             if(FileCapture = BufferOpen(SharedBuffer,"a"))
  276.             {
  277.                     /* Set the menu checkmark. */
  278.  
  279.                 CheckItem(MEN_CAPTURE_TO_FILE,TRUE);
  280.  
  281.                     /* Remember the current capture file name. */
  282.  
  283.                 strcpy(CaptureName,SharedBuffer);
  284.  
  285.                     /* Add the creation date if necessary. */
  286.  
  287.                 if(Config -> CaptureConfig -> AutoCaptureDate == AUTOCAPTURE_DATE_INCLUDE)
  288.                     BPrintf(FileCapture,LocaleString(MSG_DIALPANEL_FILE_CREATED_TXT),Time,Date);
  289.             }
  290.             else
  291.                 CheckItem(MEN_CAPTURE_TO_FILE,FALSE);
  292.  
  293.             ConOutputUpdate();
  294.         }
  295.     }
  296. }
  297.  
  298.     /* DialPanel():
  299.      *
  300.      *    This routine opens a small window in the middle of the
  301.      *    console window and walks down the list of numbers to
  302.      *    dial.
  303.      */
  304.  
  305. BYTE
  306. DialPanel()
  307. {
  308.     struct Gadget        *GadgetList = NULL;
  309.     struct Gadget        *GadgetArray[GADGET_COUNT];
  310.     struct TextBox        *BoxList = NULL;
  311.     struct TextBox        *BoxArray[BOX_COUNT];
  312.     struct Window        *PanelWindow;
  313.     struct PhoneNode    *DialNode;
  314.     BYTE             Result = FALSE;
  315.  
  316.     ChosenEntry = NULL;
  317.  
  318.         /* We are dialing. */
  319.  
  320.     Status = STATUS_DIALING;
  321.  
  322.         /* Create the gadgets. */
  323.  
  324.     if(CreateAllGadgets(BoxArray,&BoxList,GadgetArray,&GadgetList))
  325.     {
  326.             /* At last, open the window. */
  327.  
  328.         if(PanelWindow = OpenWindowTags(NULL,
  329.             WA_Left,    GetScreenLeft(Window) + (GetScreenWidth(Window) - SZ_GetWindowWidth()) / 2,
  330.             WA_Top,        GetScreenTop(Window) + (GetScreenHeight(Window) - SZ_GetWindowHeight())    / 2,
  331.             WA_Width,    SZ_GetWindowWidth(),
  332.             WA_Height,    SZ_GetWindowHeight(),
  333.  
  334.             WA_Activate,    TRUE,
  335.             WA_DragBar,    TRUE,
  336.             WA_DepthGadget,    TRUE,
  337.             WA_CloseGadget,    TRUE,
  338.             WA_RMBTrap,    TRUE,
  339.             WA_CustomScreen,Window -> WScreen,
  340.  
  341.             WA_IDCMP,    IDCMP_CLOSEWINDOW | IDCMP_VANILLAKEY | IDCMP_RAWKEY | BUTTONIDCMP,
  342.  
  343.             WA_Title,    LocaleString(MSG_DIALPANEL_DIALING_TXT),
  344.         TAG_DONE))
  345.         {
  346.             struct IntuiMessage    *Massage;
  347.             ULONG             IClass,Code;
  348.             struct Gadget        *Gadget;
  349.             LONG             RedialDelay = 0,DialTimeout,DialRetries,DialAttempt;
  350.             BYTE             Dialing,Terminated = FALSE,RunCount = 0,GotError = FALSE;
  351.  
  352.             UBYTE             SomeBuffer[300],ExitString[80],
  353.                          NumberBuffer[100],    *NextNumber    = NULL,
  354.                          InitBuffer[80],    *NextInit    = NULL,
  355.                          ExitBuffer[80],    *NextExit    = NULL,
  356.                          PrefixBuffer[80],    *NextPrefix    = NULL;
  357.  
  358.             GuideContext(CONTEXT_DIAL);
  359.  
  360.             ExitString[0] = 0;
  361.  
  362.                 /* Make the current one the active one. */
  363.  
  364.             PushWindow(PanelWindow);
  365.  
  366.                 /* Make a backup of the current configuration. */
  367.  
  368.             SaveConfig(Config,PrivateConfig);
  369.  
  370.                 /* Add the gadgets and refresh them. */
  371.  
  372.             AddGList(PanelWindow,GadgetList,(UWORD)-1,(UWORD)-1,NULL);
  373.             RefreshGList(GadgetList,PanelWindow,NULL,(UWORD)-1);
  374.             GT_RefreshWindow(PanelWindow,NULL);
  375.  
  376.             SZ_DrawBoxes(PanelWindow -> RPort,BoxList);
  377.  
  378.                 /* Don't echo serial output. */
  379.  
  380.             Quiet        = TRUE;
  381.  
  382.                 /* Perform full sequence check. */
  383.  
  384.             FullCheck    = TRUE;
  385.  
  386.                 /* Reset the scanner. */
  387.  
  388.             FlowInit(TRUE);
  389.  
  390.                 /* Reset the number of dial attempts. */
  391.  
  392.             DialAttempt    = 0;
  393.  
  394.                 /* Get the first dial list entry. */
  395.  
  396.             DialNode    = (struct PhoneNode *)DialList -> lh_Head;
  397.  
  398.                 /* The big dialing loop, implemented as a goto -> mark
  399.                  * loop rather than one of those classical while .. do
  400.                  * loops.
  401.                  */
  402.  
  403. Dial:            Dialing        = TRUE;
  404.  
  405.                 /* Reset the sequence scanner, the user may have skipped
  406.                  * the previous dial attempt causing the modem to return
  407.                  * `NO CARRIER'. To prevent the dialer from skipping the
  408.                  * next dial entry as well as the previous we have to
  409.                  * flush any data pending on the serial line.
  410.                  */
  411.  
  412.             HandleSerial();
  413.  
  414.             FlowInit(TRUE);
  415.  
  416.                 /* Now for multiple phone numbers separated
  417.                  * by `|' characters. If `NextNumber' happens
  418.                  * to be zero, we will prepare to extract
  419.                  * the first phone number from the list.
  420.                  * In any other case we will try to obtain
  421.                  * the next number.
  422.                  */
  423.  
  424.             if(NextNumber)
  425.             {
  426.                 NextNumber    = ExtractString(NextNumber,    NumberBuffer,TRUE);
  427.                 NextInit    = ExtractString(NextInit,    InitBuffer,FALSE);
  428.                 NextExit    = ExtractString(NextExit,    ExitBuffer,FALSE);
  429.                 NextPrefix    = ExtractString(NextPrefix,    PrefixBuffer,FALSE);
  430.             }
  431.             else
  432.             {
  433.                 if(DialNode -> Entry)
  434.                 {
  435.                     NextNumber = ExtractString(DialNode -> Entry -> Header -> Number,NumberBuffer,TRUE);
  436.  
  437.                     if(DialNode -> Entry -> Config -> ModemConfig)
  438.                     {
  439.                         NextInit    = ExtractString(DialNode -> Entry -> Config -> ModemConfig -> ModemInit,InitBuffer,FALSE);
  440.                         NextExit    = ExtractString(DialNode -> Entry -> Config -> ModemConfig -> ModemExit,ExitBuffer,FALSE);
  441.                         NextPrefix    = ExtractString(DialNode -> Entry -> Config -> ModemConfig -> DialPrefix,PrefixBuffer,FALSE);
  442.                     }
  443.                     else
  444.                     {
  445.                         NextInit    = ExtractString(Config -> ModemConfig -> ModemInit,InitBuffer,FALSE);
  446.                         NextExit    = ExtractString(Config -> ModemConfig -> ModemExit,ExitBuffer,FALSE);
  447.                         NextPrefix    = ExtractString(Config -> ModemConfig -> DialPrefix,PrefixBuffer,FALSE);
  448.                     }
  449.                 }
  450.                 else
  451.                 {
  452.                     NextNumber    = ExtractString(DialNode -> VanillaNode . ln_Name,NumberBuffer,TRUE);
  453.  
  454.                     NextInit    = ExtractString(Config -> ModemConfig -> ModemInit,InitBuffer,FALSE);
  455.                     NextExit    = ExtractString(Config -> ModemConfig -> ModemExit,ExitBuffer,FALSE);
  456.                     NextPrefix    = ExtractString(Config -> ModemConfig -> DialPrefix,PrefixBuffer,FALSE);
  457.                 }
  458.             }
  459.  
  460.                 /* If DialNode -> Entry is nonzero it has
  461.                  * a configuration attached.
  462.                  */
  463.  
  464.             if(DialNode -> Entry)
  465.             {
  466.                 if(DialNode -> Entry -> Config -> ModemConfig)
  467.                 {
  468.                     DialTimeout    = DialNode -> Entry -> Config -> ModemConfig -> DialTimeout;
  469.                     DialRetries    = DialNode -> Entry -> Config -> ModemConfig -> DialRetries;
  470.                 }
  471.                 else
  472.                 {
  473.                     DialTimeout    = Config -> ModemConfig -> DialTimeout;
  474.                     DialRetries    = Config -> ModemConfig -> DialRetries;
  475.                 }
  476.  
  477.                     /* Send the modem exit string before we
  478.                      * will need to reconfigure the serial
  479.                      * device driver.
  480.                      */
  481.  
  482.                 if(ExitString[0])
  483.                 {
  484.                     SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_MESSAGE],0,LocaleString(MSG_DIALPANEL_SENDING_MODEM_EXIT_COMMAND_TXT));
  485.  
  486.                     FlowInit(TRUE);
  487.  
  488.                     SerialCommand(ExitString);
  489.  
  490.                     WaitTime(1,0);
  491.  
  492.                     HandleSerial();
  493.  
  494.                     if(FlowInfo . Changed && FlowInfo . Error)
  495.                     {
  496.                         SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_MESSAGE],0,LocaleString(MSG_DIALPANEL_ERROR_SENDING_MODEM_COMMAND_TXT));
  497.  
  498.                         GotError = TRUE;
  499.  
  500.                         goto Quit;
  501.                     }
  502.                 }
  503.  
  504.                     /* We will need to change the serial parameters
  505.                      * in order to establish a connection.
  506.                      */
  507.  
  508.                 if(DialNode -> Entry -> Config -> SerialConfig)
  509.                 {
  510.                     if(ReconfigureSerial(PanelWindow,DialNode -> Entry -> Config -> SerialConfig) == RECONFIGURE_FAILURE)
  511.                         goto Quit;
  512.                 }
  513.  
  514.                     /* Send the modem init string. */
  515.  
  516.                 if(InitBuffer[0] && !Terminated)
  517.                 {
  518.                     SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_MESSAGE],0,LocaleString(MSG_DIALPANEL_SENDING_MODEM_INIT_COMMAND_TXT));
  519.  
  520.                     FlowInit(TRUE);
  521.  
  522.                     SerialCommand(InitBuffer);
  523.  
  524.                     WaitTime(1,0);
  525.  
  526.                     HandleSerial();
  527.  
  528.                     if(FlowInfo . Changed && FlowInfo . Error)
  529.                     {
  530.                         SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_MESSAGE],0,LocaleString(MSG_DIALPANEL_ERROR_SENDING_MODEM_COMMAND_TXT));
  531.  
  532.                         GotError = TRUE;
  533.  
  534.                         goto Quit;
  535.                     }
  536.                 }
  537.  
  538.                     /* Remember the new exit string. */
  539.  
  540.                 strcpy(ExitString,ExitBuffer);
  541.  
  542.                 SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_CALL_COMMENT_NUMBER_NEXT],0,DialNode -> Entry -> Header -> Name);
  543.  
  544.                 if(DialNode -> Entry -> Header -> Comment[0])
  545.                     SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_CALL_COMMENT_NUMBER_NEXT],1,DialNode -> Entry -> Header -> Comment);
  546.                 else
  547.                     SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_CALL_COMMENT_NUMBER_NEXT],1,"-");
  548.  
  549.                 Say(LocaleString(MSG_DIALPANEL_NOW_CALLING_TXT),DialNode -> Entry -> Header -> Name);
  550.  
  551.                 strcpy(SomeBuffer,PrefixBuffer);
  552.  
  553.                 SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_CALL_COMMENT_NUMBER_NEXT],2,NumberBuffer);
  554.  
  555.                 strcat(SomeBuffer,NumberBuffer);
  556.             }
  557.             else
  558.             {
  559.                 DialTimeout    = Config -> ModemConfig -> DialTimeout;
  560.                 DialRetries    = Config -> ModemConfig -> DialRetries;
  561.  
  562.                     /* Send the modem exit string. */
  563.  
  564.                 if(ExitString[0])
  565.                 {
  566.                     SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_MESSAGE],0,LocaleString(MSG_DIALPANEL_SENDING_MODEM_EXIT_COMMAND_TXT));
  567.  
  568.                     FlowInit(TRUE);
  569.  
  570.                     SerialCommand(ExitBuffer);
  571.  
  572.                     WaitTime(1,0);
  573.  
  574.                     HandleSerial();
  575.  
  576.                     if(FlowInfo . Changed && FlowInfo . Error)
  577.                     {
  578.                         SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_MESSAGE],0,LocaleString(MSG_DIALPANEL_ERROR_SENDING_MODEM_COMMAND_TXT));
  579.  
  580.                         GotError = TRUE;
  581.  
  582.                         goto Quit;
  583.                     }
  584.                 }
  585.  
  586.                     /* Remember the new exit string. */
  587.  
  588.                 strcpy(ExitString,ExitBuffer);
  589.  
  590.                 SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_CALL_COMMENT_NUMBER_NEXT],0,LocaleString(MSG_GLOBAL_UNKNOWN_TXT));
  591.  
  592.                 SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_CALL_COMMENT_NUMBER_NEXT],1,"-");
  593.  
  594.                 Say(LocaleString(MSG_DIALPANEL_NOW_CALLING_TXT),NumberBuffer);
  595.  
  596.                 strcpy(SomeBuffer,PrefixBuffer);
  597.  
  598.                 SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_CALL_COMMENT_NUMBER_NEXT],2,NumberBuffer);
  599.  
  600.                 strcat(SomeBuffer,NumberBuffer);
  601.  
  602.                     /* Send the modem init string. */
  603.  
  604.                 if(InitBuffer[0])
  605.                 {
  606.                     SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_MESSAGE],0,LocaleString(MSG_DIALPANEL_SENDING_MODEM_INIT_COMMAND_TXT));
  607.  
  608.                     FlowInit(TRUE);
  609.  
  610.                     SerialCommand(InitBuffer);
  611.  
  612.                     WaitTime(1,0);
  613.  
  614.                     HandleSerial();
  615.  
  616.                     if(FlowInfo . Changed && FlowInfo . Error)
  617.                     {
  618.                         SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_MESSAGE],0,LocaleString(MSG_DIALPANEL_ERROR_SENDING_MODEM_COMMAND_TXT));
  619.  
  620.                         GotError = TRUE;
  621.  
  622.                         goto Quit;
  623.                     }
  624.                 }
  625.             }
  626.  
  627.             if(NextNumber)
  628.             {
  629.                 if(DialNode -> Entry)
  630.                     SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_CALL_COMMENT_NUMBER_NEXT],3,DialNode -> Entry -> Header -> Name);
  631.                 else
  632.                     SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_CALL_COMMENT_NUMBER_NEXT],3,DialNode -> VanillaNode . ln_Name);
  633.             }
  634.             else
  635.             {
  636.                 if(DialNode -> VanillaNode . ln_Succ -> ln_Succ)
  637.                 {
  638.                     if(DialNode -> Entry)
  639.                         SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_CALL_COMMENT_NUMBER_NEXT],3,((struct PhoneNode *)DialNode -> VanillaNode . ln_Succ) -> Entry -> Header -> Name);
  640.                     else
  641.                         SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_CALL_COMMENT_NUMBER_NEXT],3,DialNode -> VanillaNode . ln_Succ -> ln_Name);
  642.                 }
  643.                 else
  644.                     SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_CALL_COMMENT_NUMBER_NEXT],3,LocaleString(MSG_GLOBAL_NONE_TXT));
  645.             }
  646.  
  647.             if(DialNode -> Entry)
  648.             {
  649.                 if(DialNode -> Entry -> Config -> ModemConfig)
  650.                     strcat(SomeBuffer,DialNode -> Entry -> Config -> ModemConfig -> DialSuffix);
  651.                 else
  652.                     strcat(SomeBuffer,Config -> ModemConfig -> DialSuffix);
  653.             }
  654.             else
  655.                 strcat(SomeBuffer,Config -> ModemConfig -> DialSuffix);
  656.  
  657.             SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_MESSAGE],0,LocaleString(MSG_DIALPANEL_DIALING_TXT));
  658.  
  659.                 /* Dial the number. */
  660.  
  661.             SerialCommand(SomeBuffer);
  662.  
  663.                 /* Reset the signal. */
  664.  
  665.             SetSignal(NULL,SIG_SKIP | SIG_BREAK);
  666.  
  667.             while(!Terminated)
  668.             {
  669.                 if(CheckSignal(SIG_BREAK))
  670.                 {
  671.                     Terminated = TRUE;
  672.  
  673.                     SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_MESSAGE],0,LocaleString(MSG_DIALPANEL_ABORTING_TXT));
  674.  
  675.                     SerWrite("\r",1);
  676.                     WaitTime(1,0);
  677.  
  678.                         /* Ignore the response of the modem. */
  679.  
  680.                     HandleSerial();
  681.  
  682.                     FlowInit(TRUE);
  683.  
  684.                     break;
  685.                 }
  686.  
  687.                 if(Dialing)
  688.                 {
  689.                     SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_TIME_TRY],0,"%2ld:%02ld",DialTimeout / 60,DialTimeout % 60);
  690.                     SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_TIME_TRY],1,LocaleString(MSG_DIALPANEL_ATTEMPT_OF_TXT),DialAttempt + 1,DialRetries);
  691.                 }
  692.                 else
  693.                     SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_TIME_TRY],0,"%2ld:%02ld",RedialDelay / 60,RedialDelay % 60);
  694.  
  695.                 WaitTime(0,MILLION / 2);
  696.  
  697.                     /* The following commands are executed each second */
  698.  
  699.                 if((RunCount++) && !Terminated)
  700.                 {
  701.                     RunCount = 0;
  702.  
  703.                         /* Are we dialing or waiting? */
  704.  
  705.                     if(Dialing)
  706.                     {
  707.                             /* No chance, the dial timeout
  708.                              * has elapsed and no connection
  709.                              * was made.
  710.                              */
  711.  
  712.                         if(!(--DialTimeout))
  713.                         {
  714.                             SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_MESSAGE],0,LocaleString(MSG_DIALPANEL_DIAL_ATTEMPT_TIMEOUT_TXT));
  715.  
  716. Skip1:                            SerWrite("\r",1);
  717.                             WaitTime(1,0);
  718.  
  719.                                 /* Ignore the response of the modem. */
  720.  
  721.                             HandleSerial();
  722.  
  723.                             FlowInit(TRUE);
  724.  
  725.                                 /* Did we dial all the numbers available? */
  726.  
  727.                             if(NextNumber)
  728.                                 goto Dial;
  729.  
  730.                                 /* Is this one the last entry? */
  731.  
  732.                             if(DialNode -> VanillaNode . ln_Succ -> ln_Succ)
  733.                             {
  734.                                     /* Proceed to the next entry. */
  735.  
  736.                                 DialNode = (struct PhoneNode *)DialNode -> VanillaNode . ln_Succ;
  737.  
  738.                                 goto Dial;
  739.                             }
  740.                             else
  741.                             {
  742.                                     /* Is this one the last dial
  743.                                      * attempt to be made?
  744.                                      */
  745.  
  746.                                 if(++DialAttempt >= DialRetries)
  747.                                 {
  748.                                     SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_MESSAGE],0,LocaleString(MSG_DIALPANEL_MAXIMUM_NUMBER_OF_DIAL_RETRIES_TXT));
  749.  
  750.                                     WakeUp(PanelWindow,SOUND_BELL);
  751.  
  752.                                     WaitTime(2,0);
  753.  
  754.                                     Say(LocaleString(MSG_DIALPANEL_MAXIMUM_NUMBER_OF_DIAL_RETRIES_TXT));
  755.  
  756.                                     Terminated = TRUE;
  757.                                 }
  758.                                 else
  759.                                 {
  760.                                         /* Get the first list entry. */
  761.  
  762.                                     DialNode = (struct PhoneNode *)DialList -> lh_Head;
  763.  
  764.                                         /* Get the redial delay. */
  765.  
  766.                                     if(DialNode -> Entry)
  767.                                     {
  768.                                         if(DialNode -> Entry -> Config -> ModemConfig)
  769.                                             RedialDelay = 10 * DialNode -> Entry -> Config -> ModemConfig -> RedialDelay;
  770.                                         else
  771.                                             RedialDelay = 10 * Config -> ModemConfig -> RedialDelay;
  772.                                     }
  773.                                     else
  774.                                         RedialDelay = 10 * Config -> ModemConfig -> RedialDelay;
  775.  
  776.                                         /* No redial delay? Restart dialing... */
  777.  
  778.                                     if(!RedialDelay)
  779.                                     {
  780.                                         WaitTime(1,0);
  781.  
  782.                                         goto Dial;
  783.                                     }
  784.                                     else
  785.                                     {
  786.                                             /* Go into redial delay. */
  787.  
  788.                                         SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_MESSAGE],0,LocaleString(MSG_DIALPANEL_REDIAL_DELAY_TXT));
  789.  
  790.                                         Dialing = FALSE;
  791.  
  792.                                         Say(LocaleString(MSG_DIALPANEL_WAITING_TXT));
  793.                                     }
  794.                                 }
  795.                             }
  796.                         }
  797.                     }
  798.                     else
  799.                     {
  800.                         if(!(--RedialDelay))
  801.                         {
  802.                                 /* Get the first list entry. */
  803.  
  804. Skip2:                            DialNode = (struct PhoneNode *)DialList -> lh_Head;
  805.  
  806.                                 /* We are once again dialing. */
  807.  
  808.                             goto Dial;
  809.                         }
  810.                     }
  811.                 }
  812.  
  813.                     /* Handle serial data flow. */
  814.  
  815.                 HandleSerial();
  816.  
  817.                     /* Something has changed in the flow
  818.                      * info structure.
  819.                      */
  820.  
  821.                 if(FlowInfo . Changed)
  822.                 {
  823.                         /* Current number is busy. */
  824.  
  825.                     if(FlowInfo . Busy || (FlowInfo . NoCarrier && Config -> ModemConfig -> NoCarrierIsBusy))
  826.                     {
  827.                         FlowInit(TRUE);
  828.  
  829.                         FlowInfo . Busy        = FALSE;
  830.                         FlowInfo . NoCarrier    = FALSE;
  831.                         FlowInfo . Changed    = FALSE;
  832.  
  833.                         if(Dialing)
  834.                         {
  835.                             SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_MESSAGE],0,LocaleString(MSG_DIALPANEL_LINE_IS_BUSY_TXT));
  836.  
  837.                             Say(LocaleString(MSG_DIALPANEL_LINE_IS_BUSY_TXT));
  838.  
  839.                             WaitTime(1,0);
  840.  
  841.                             goto Skip1;
  842.                         }
  843.                     }
  844.  
  845.                         /* Line does not feature a dialtone. */
  846.  
  847.                     if(FlowInfo . NoDialTone)
  848.                     {
  849.                         FlowInit(TRUE);
  850.  
  851.                         SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_MESSAGE],0,LocaleString(MSG_DIALPANEL_NO_DIALTONE_TXT));
  852.  
  853.                         WakeUp(PanelWindow,SOUND_BELL);
  854.  
  855.                         WaitTime(2,0);
  856.  
  857.                         Say(LocaleString(MSG_DIALPANEL_NO_DIALTONE_TXT));
  858.  
  859.                         Terminated = TRUE;
  860.                     }
  861.  
  862.                         /* Somebody tries to call us. */
  863.  
  864.                     if(FlowInfo . Ring && !Terminated)
  865.                     {
  866.                         FlowInit(TRUE);
  867.  
  868.                         SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_MESSAGE],0,LocaleString(MSG_GLOBAL_INCOMING_CALL_TXT));
  869.  
  870.                         WakeUp(PanelWindow,SOUND_RING);
  871.  
  872.                         WaitTime(2,0);
  873.  
  874.                         Say(LocaleString(MSG_GLOBAL_INCOMING_CALL_TXT));
  875.  
  876.                         Terminated = TRUE;
  877.                     }
  878.  
  879.                         /* Somebody's talking. */
  880.  
  881.                     if(FlowInfo . Voice && !Terminated)
  882.                     {
  883.                         FlowInit(TRUE);
  884.  
  885.                         SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_MESSAGE],0,LocaleString(MSG_DIALPANEL_INCOMING_VOICE_CALL_TXT));
  886.  
  887.                         WakeUp(PanelWindow,SOUND_VOICE);
  888.  
  889.                         WaitTime(2,0);
  890.  
  891.                         Say(LocaleString(MSG_DIALPANEL_INCOMING_VOICE_CALL_TXT));
  892.  
  893.                         Terminated = TRUE;
  894.                     }
  895.  
  896.                         /* We got a connect. */
  897.  
  898.                     if(FlowInfo . Connect && !Terminated)
  899.                     {
  900.                         FlowInfo . Connect = FALSE;
  901.                         FlowInfo . Changed = FALSE;
  902.  
  903.                             /* Install the new configuration. */
  904.  
  905.                         if(DialNode -> Entry)
  906.                         {
  907.                             UpdateConfig(DialNode -> Entry -> Config,Config);
  908.  
  909.                             ConfigChanged = FALSE;
  910.  
  911.                             MakeCall(DialNode -> Entry -> Header -> Name,NumberBuffer);
  912.                         }
  913.                         else
  914.                             MakeCall("???",NumberBuffer);
  915.  
  916.                             /* Reset the scanner. */
  917.  
  918.                         FlowInit(TRUE);
  919.  
  920.                             /* Copy the remaining data. */
  921.  
  922.                         if(DialNode -> Entry)
  923.                         {
  924.                             SelectTime(DialNode -> Entry);
  925.  
  926.                             ChosenEntry    = DialNode -> Entry;
  927.                             WhichUnit    = DT_FIRST_UNIT;
  928.                             CurrentPay    = 0;
  929.                             SendStartup    = TRUE;
  930.  
  931.                             strcpy(Password,DialNode -> Entry -> Header -> Password);
  932.                             strcpy(UserName,DialNode -> Entry -> Header -> UserName);
  933.  
  934.                             strcpy(CurrentBBSName,DialNode -> Entry -> Header -> Name);
  935.                             strcpy(CurrentBBSComment,DialNode -> Entry -> Header -> Comment);
  936.  
  937.                             strcpy(CurrentBBSNumber,NumberBuffer);
  938.  
  939.                             if(DialNode -> Entry -> Config && DialNode -> Entry -> Config -> ModemConfig)
  940.                             {
  941.                                 OnlinePlus = DialNode -> Entry -> Config -> ModemConfig -> TimeToConnect;
  942.  
  943.                                 if(DialNode -> Entry -> Config -> ModemConfig -> ConnectLimit > 0 && DialNode -> Entry -> Config -> ModemConfig -> ConnectLimitMacro[0])
  944.                                 {
  945.                                     LimitCount = DialNode -> Entry -> Config -> ModemConfig -> ConnectLimit;
  946.  
  947.                                     strcpy(LimitMacro,DialNode -> Entry -> Config -> ModemConfig -> ConnectLimitMacro);
  948.                                 }
  949.                                 else
  950.                                     LimitCount = -1;
  951.                             }
  952.                             else
  953.                             {
  954.                                 OnlinePlus = Config -> ModemConfig -> TimeToConnect;
  955.  
  956.                                 if(Config -> ModemConfig -> ConnectLimit > 0 && Config -> ModemConfig -> ConnectLimitMacro[0])
  957.                                 {
  958.                                     LimitCount = Config -> ModemConfig -> ConnectLimit;
  959.  
  960.                                     strcpy(LimitMacro,Config -> ModemConfig -> ConnectLimitMacro);
  961.                                 }
  962.                                 else
  963.                                     LimitCount = -1;
  964.                             }
  965.                         }
  966.                         else
  967.                         {
  968.                             OnlinePlus = Config -> ModemConfig -> TimeToConnect;
  969.  
  970.                             CurrentPay        = 0;
  971.  
  972.                             ChosenEntry        = NULL;
  973.  
  974.                             CurrentBBSName[0]    = 0;
  975.                             CurrentBBSComment[0]    = 0;
  976.  
  977.                             strcpy(CurrentBBSNumber,NumberBuffer);
  978.  
  979.                             Password[0]        = 0;
  980.                             UserName[0]        = 0;
  981.  
  982.                             SendStartup        = FALSE;
  983.  
  984.                             if(Config -> ModemConfig -> ConnectLimit > 0 && Config -> ModemConfig -> ConnectLimitMacro[0])
  985.                             {
  986.                                 LimitCount = Config -> ModemConfig -> ConnectLimit;
  987.  
  988.                                 strcpy(LimitMacro,Config -> ModemConfig -> ConnectLimitMacro);
  989.                             }
  990.                             else
  991.                                 LimitCount = -1;
  992.                         }
  993.  
  994.                             /* We are now online. */
  995.  
  996.                         Online        = TRUE;
  997.                         Terminated    = TRUE;
  998.  
  999.                             /* Add another logfile entry. */
  1000.  
  1001.                         if(DialNode -> Entry)
  1002.                             LogAction(LocaleString(MSG_DIALPANEL_CONNECTED_TO_1_TXT),DialNode -> Entry -> Header -> Name,NumberBuffer);
  1003.                         else
  1004.                             LogAction(LocaleString(MSG_DIALPANEL_CONNECTED_TO_2_TXT),NumberBuffer);
  1005.  
  1006.                             /* Open auto-capture file if necessary. */
  1007.  
  1008.                         if(Config -> CaptureConfig -> ConnectAutoCapture && Config -> CaptureConfig -> CapturePath[0])
  1009.                         {
  1010.                             if(DialNode -> Entry)
  1011.                                 OpenAutoCaptureFile(DialNode -> Entry -> Header -> Name);
  1012.                             else
  1013.                                 OpenAutoCaptureFile(LocaleString(MSG_DIALPANEL_CAPTURE_NAME_TXT));
  1014.                         }
  1015.  
  1016.                             /* Remove the node from the
  1017.                              * dialing list.
  1018.                              */
  1019.  
  1020.                         if(DialNode -> Entry)
  1021.                             RemoveDialNode(DialNode);
  1022.  
  1023.                         Remove(&DialNode -> VanillaNode);
  1024.  
  1025.                         FreeVec(DialNode);
  1026.  
  1027.                         if(PrivateConfig -> MiscConfig -> BackupConfig)
  1028.                         {
  1029.                             if(!BackupConfig)
  1030.                             {
  1031.                                 if(BackupConfig = CreateConfiguration(TRUE))
  1032.                                     SaveConfig(PrivateConfig,BackupConfig);
  1033.                             }
  1034.                         }
  1035.  
  1036.                             /* Make sure that the following
  1037.                              * setup/initialization will not
  1038.                              * touch the serial configuration.
  1039.                              */
  1040.  
  1041.                         memcpy(PrivateConfig -> SerialConfig,Config -> SerialConfig,sizeof(struct SerialSettings));
  1042.  
  1043.                             /* Wake the user up. */
  1044.  
  1045.                         if(BaudBuffer[0])
  1046.                         {
  1047.                             strcpy(SharedBuffer,"CONNECT ");
  1048.                             strcat(SharedBuffer,BaudBuffer);
  1049.  
  1050.                             SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_MESSAGE],0,SharedBuffer);
  1051.  
  1052.                             WakeUp(PanelWindow,SOUND_CONNECT);
  1053.  
  1054.                             WaitTime(2,0);
  1055.  
  1056.                                 /* Install new baud rate if desired. */
  1057.  
  1058.                             if(Config -> ModemConfig -> ConnectAutoBaud && DTERate > 110)
  1059.                             {
  1060.                                 Config -> SerialConfig -> BaudRate = DTERate;
  1061.  
  1062.                                 ReconfigureSerial(PanelWindow,NULL);
  1063.                             }
  1064.                         }
  1065.                         else
  1066.                         {
  1067.                             SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_MESSAGE],0,LocaleString(MSG_DIALPANEL_CONNECTION_ESTABLISHED_TXT));
  1068.  
  1069.                             WakeUp(PanelWindow,SOUND_CONNECT);
  1070.                         }
  1071.  
  1072.                         Say(LocaleString(MSG_DIALPANEL_CONNECTION_ESTABLISHED_TXT));
  1073.  
  1074.                             /* Perform system initialization. */
  1075.  
  1076.                         ConfigSetup();
  1077.                     }
  1078.                 }
  1079.  
  1080.                     /* Look for the hotkey. */
  1081.  
  1082.                 if(CheckSignal(SIG_SKIP))
  1083.                 {
  1084.                         /* Are we dialing or waiting? */
  1085.  
  1086.                     if(Dialing)
  1087.                     {
  1088.                         DialTimeout = 0;
  1089.  
  1090.                         goto Skip1;
  1091.                     }
  1092.                     else
  1093.                     {
  1094.                         RedialDelay = 0;
  1095.  
  1096.                         goto Skip2;
  1097.                     }
  1098.                 }
  1099.  
  1100.                     /* Pick up the window input. */
  1101.  
  1102.                 while(!Terminated && (Massage = (struct IntuiMessage *)GT_GetIMsg(PanelWindow -> UserPort)))
  1103.                 {
  1104.                     IClass    = Massage -> Class;
  1105.                     Code    = Massage -> Code;
  1106.                     Gadget    = (struct Gadget *)Massage -> IAddress;
  1107.  
  1108.                     GT_ReplyIMsg(Massage);
  1109.  
  1110.                     if(IClass == IDCMP_VANILLAKEY)
  1111.                     {
  1112.                         if(Code == ' ')
  1113.                         {
  1114.                             IClass    = IDCMP_GADGETUP;
  1115.                             Code    = 0;
  1116.                             Gadget    = GadgetArray[GAD_SKIP];
  1117.                         }
  1118.                         else
  1119.                             KeySelect(GadgetArray,GAD_ABORT,Code,PanelWindow,&Gadget,&IClass,&Code);
  1120.                     }
  1121.  
  1122.                     if(IClass == IDCMP_RAWKEY)
  1123.                         KeySelect(GadgetArray,GAD_ABORT,Code,PanelWindow,&Gadget,&IClass,&Code);
  1124.  
  1125.                         /* Close the window, hang up the line. */
  1126.  
  1127.                     if(IClass == IDCMP_CLOSEWINDOW)
  1128.                     {
  1129.                         IClass    = IDCMP_GADGETUP;
  1130.                         Gadget    = GadgetArray[GAD_ABORT];
  1131.  
  1132.                         Result = TRUE;
  1133.                     }
  1134.  
  1135.                     if(IClass == IDCMP_GADGETUP)
  1136.                     {
  1137.                         switch(Gadget -> GadgetID)
  1138.                         {
  1139.                                     /* Don't proceed to the next number in the buffer! */
  1140.  
  1141.                             case GAD_REMOVE:
  1142.  
  1143.                                 NextNumber = NULL;
  1144.  
  1145.                                 if(Dialing)
  1146.                                 {
  1147.                                     struct PhoneNode *NextNode = NULL;
  1148.  
  1149.                                         /* Is there another entry in the list? */
  1150.  
  1151.                                     if(DialNode -> VanillaNode . ln_Succ -> ln_Succ)
  1152.                                         NextNode = (struct PhoneNode *)DialNode -> VanillaNode . ln_Succ;
  1153.                                     else
  1154.                                     {
  1155.                                             /* No, there isn't; do we have a list with
  1156.                                              * at least two entries in it?
  1157.                                              */
  1158.  
  1159.                                         if(DialList -> lh_Head -> ln_Succ -> ln_Succ)
  1160.                                         {
  1161.                                                 /* There is just a single entry
  1162.                                                  * available, check for dial retry
  1163.                                                  * limit.
  1164.                                                  */
  1165.  
  1166.                                             if(++DialAttempt >= DialRetries)
  1167.                                             {
  1168.                                                 SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_MESSAGE],0,LocaleString(MSG_DIALPANEL_MAXIMUM_NUMBER_OF_DIAL_RETRIES_TXT));
  1169.  
  1170.                                                 WakeUp(PanelWindow,SOUND_BELL);
  1171.  
  1172.                                                 WaitTime(2,0);
  1173.  
  1174.                                                 Say(LocaleString(MSG_DIALPANEL_MAXIMUM_NUMBER_OF_DIAL_RETRIES_TXT));
  1175.  
  1176.                                                 Terminated = TRUE;
  1177.                                             }
  1178.                                             else
  1179.                                             {
  1180.                                                     /* Grab first list entry and continue. */
  1181.  
  1182.                                                 NextNode = (struct PhoneNode *)DialList -> lh_Head;
  1183.                                             }
  1184.                                         }
  1185.                                         else
  1186.                                         {
  1187.                                             Terminated = TRUE;
  1188.  
  1189.                                             SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_MESSAGE],0,LocaleString(MSG_DIALPANEL_DIALING_LIST_IS_EMPTY_TXT));
  1190.  
  1191.                                             WaitTime(2,0);
  1192.                                         }
  1193.                                     }
  1194.  
  1195.                                     DialTimeout = 0;
  1196.  
  1197.                                     SerWrite("\r",1);
  1198.                                     WaitTime(1,0);
  1199.  
  1200.                                         /* Ignore the response of the modem. */
  1201.  
  1202.                                     HandleSerial();
  1203.  
  1204.                                     FlowInit(TRUE);
  1205.  
  1206.                                         /* Remove dial entry from list. */
  1207.  
  1208.                                     if(DialNode -> Entry)
  1209.                                         RemoveDialNode(DialNode);
  1210.  
  1211.                                     Remove(&DialNode -> VanillaNode);
  1212.  
  1213.                                     FreeVec(DialNode);
  1214.  
  1215.                                         /* Is there an entry to proceed with? */
  1216.  
  1217.                                     if(NextNode)
  1218.                                     {
  1219.                                         DialNode = NextNode;
  1220.  
  1221.                                         goto Dial;
  1222.                                     }
  1223.                                 }
  1224.                                 else
  1225.                                 {
  1226.                                     struct PhoneNode *LastNode;
  1227.  
  1228.                                         /* We are to leave the redial delay loop,
  1229.                                          * are there at least two entries in
  1230.                                          * the list?
  1231.                                          */
  1232.  
  1233.                                     if(!DialList -> lh_Head -> ln_Succ -> ln_Succ)
  1234.                                     {
  1235.                                             /* No, there is just a single entry in
  1236.                                              * the list.
  1237.                                              */
  1238.  
  1239.                                         Terminated = TRUE;
  1240.  
  1241.                                         SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_MESSAGE],0,LocaleString(MSG_DIALPANEL_DIALING_LIST_IS_EMPTY_TXT));
  1242.  
  1243.                                         SerWrite("\r",1);
  1244.                                         WaitTime(2,0);
  1245.  
  1246.                                             /* Ignore the response of the modem. */
  1247.  
  1248.                                         HandleSerial();
  1249.  
  1250.                                         FlowInit(TRUE);
  1251.                                     }
  1252.  
  1253.                                         /* Remove last dial entry from list. */
  1254.  
  1255.                                     LastNode = (struct PhoneNode *)DialList -> lh_TailPred;
  1256.  
  1257.                                     if(LastNode -> Entry)
  1258.                                         RemoveDialNode(LastNode);
  1259.  
  1260.                                     Remove(&LastNode -> VanillaNode);
  1261.  
  1262.                                     FreeVec(LastNode);
  1263.  
  1264.                                         /* Get back to first list entry. */
  1265.  
  1266.                                     if(!Terminated)
  1267.                                     {
  1268.                                         RedialDelay = 0;
  1269.  
  1270.                                         goto Skip2;
  1271.                                     }
  1272.                                 }
  1273.  
  1274.                                 break;
  1275.  
  1276.                             case GAD_SKIP:
  1277.  
  1278.                                 if(Dialing)
  1279.                                 {
  1280.                                     DialTimeout = 0;
  1281.  
  1282.                                     goto Skip1;
  1283.                                 }
  1284.                                 else
  1285.                                 {
  1286.                                     RedialDelay = 0;
  1287.  
  1288.                                     goto Skip2;
  1289.                                 }
  1290.  
  1291.                             case GAD_ONLINE:
  1292.  
  1293.                                     /* Forced online,
  1294.                                      * install new configuration
  1295.                                      * first.
  1296.                                      */
  1297.  
  1298.                                 if(DialNode -> Entry)
  1299.                                 {
  1300.                                     UpdateConfig(DialNode -> Entry -> Config,Config);
  1301.  
  1302.                                     ConfigChanged = FALSE;
  1303.  
  1304.                                     MakeCall(DialNode -> Entry -> Header -> Name,NumberBuffer);
  1305.  
  1306.                                     SelectTime(DialNode -> Entry);
  1307.  
  1308.                                     ChosenEntry    = DialNode -> Entry;
  1309.                                     WhichUnit    = DT_FIRST_UNIT;
  1310.                                     CurrentPay    = 0;
  1311.                                     SendStartup    = TRUE;
  1312.  
  1313.                                     strcpy(Password,DialNode -> Entry -> Header -> Password);
  1314.                                     strcpy(UserName,DialNode -> Entry -> Header -> UserName);
  1315.  
  1316.                                     strcpy(CurrentBBSName,DialNode -> Entry -> Header -> Name);
  1317.                                     strcpy(CurrentBBSComment,DialNode -> Entry -> Header -> Comment);
  1318.  
  1319.                                     strcpy(CurrentBBSNumber,NumberBuffer);
  1320.  
  1321.                                     if(DialNode -> Entry -> Config && DialNode -> Entry -> Config -> ModemConfig)
  1322.                                     {
  1323.                                         OnlinePlus = DialNode -> Entry -> Config -> ModemConfig -> TimeToConnect;
  1324.  
  1325.                                         if(DialNode -> Entry -> Config -> ModemConfig -> ConnectLimit > 0 && DialNode -> Entry -> Config -> ModemConfig -> ConnectLimitMacro[0])
  1326.                                         {
  1327.                                             LimitCount = DialNode -> Entry -> Config -> ModemConfig -> ConnectLimit;
  1328.  
  1329.                                             strcpy(LimitMacro,DialNode -> Entry -> Config -> ModemConfig -> ConnectLimitMacro);
  1330.                                         }
  1331.                                         else
  1332.                                             LimitCount = -1;
  1333.                                     }
  1334.                                     else
  1335.                                     {
  1336.                                         OnlinePlus = Config -> ModemConfig -> TimeToConnect;
  1337.  
  1338.                                         if(Config -> ModemConfig -> ConnectLimit > 0 && Config -> ModemConfig -> ConnectLimitMacro[0])
  1339.                                         {
  1340.                                             LimitCount = Config -> ModemConfig -> ConnectLimit;
  1341.  
  1342.                                             strcpy(LimitMacro,Config -> ModemConfig -> ConnectLimitMacro);
  1343.                                         }
  1344.                                         else
  1345.                                             LimitCount = -1;
  1346.                                     }
  1347.                                 }
  1348.                                 else
  1349.                                 {
  1350.                                     OnlinePlus = Config -> ModemConfig -> TimeToConnect;
  1351.  
  1352.                                     MakeCall("???",NumberBuffer);
  1353.  
  1354.                                     CurrentPay    = 0;
  1355.                                     ChosenEntry    = NULL;
  1356.                                     Password[0]    = 0;
  1357.                                     UserName[0]    = 0;
  1358.                                     SendStartup    = FALSE;
  1359.  
  1360.                                     CurrentBBSName[0]    = 0;
  1361.                                     CurrentBBSComment[0]    = 0;
  1362.  
  1363.                                     strcpy(CurrentBBSNumber,NumberBuffer);
  1364.  
  1365.                                     if(Config -> ModemConfig -> ConnectLimit > 0 && Config -> ModemConfig -> ConnectLimitMacro[0])
  1366.                                     {
  1367.                                         LimitCount = Config -> ModemConfig -> ConnectLimit;
  1368.  
  1369.                                         strcpy(LimitMacro,Config -> ModemConfig -> ConnectLimitMacro);
  1370.                                     }
  1371.                                     else
  1372.                                         LimitCount = -1;
  1373.                                 }
  1374.  
  1375.                                     /* We are now online. */
  1376.  
  1377.                                 Online        = TRUE;
  1378.                                 Terminated    = TRUE;
  1379.  
  1380.                                     /* Add a new log action. */
  1381.  
  1382.                                 if(DialNode -> Entry)
  1383.                                     LogAction(LocaleString(MSG_DIALPANEL_CONNECTED_TO_1_TXT),DialNode -> Entry -> Header -> Name,NumberBuffer);
  1384.                                 else
  1385.                                     LogAction(LocaleString(MSG_DIALPANEL_CONNECTED_TO_2_TXT),NumberBuffer);
  1386.  
  1387.                                     /* Open auto-capture file. */
  1388.  
  1389.                                 if(Config -> CaptureConfig -> ConnectAutoCapture && Config -> CaptureConfig -> CapturePath[0])
  1390.                                 {
  1391.                                     if(DialNode -> Entry)
  1392.                                         OpenAutoCaptureFile(DialNode -> Entry -> Header -> Name);
  1393.                                     else
  1394.                                         OpenAutoCaptureFile(LocaleString(MSG_DIALPANEL_CAPTURE_NAME_TXT));
  1395.                                 }
  1396.  
  1397.                                     /* Remove node from
  1398.                                      * dialing list and
  1399.                                      * perform system
  1400.                                      * setup.
  1401.                                      */
  1402.  
  1403.                                 if(DialNode -> Entry)
  1404.                                     RemoveDialNode(DialNode);
  1405.  
  1406.                                 Remove(&DialNode -> VanillaNode);
  1407.  
  1408.                                 FreeVec(DialNode);
  1409.  
  1410.                                 if(PrivateConfig -> MiscConfig -> BackupConfig)
  1411.                                 {
  1412.                                     if(!BackupConfig)
  1413.                                     {
  1414.                                         if(BackupConfig = CreateConfiguration(TRUE))
  1415.                                             SaveConfig(PrivateConfig,BackupConfig);
  1416.                                     }
  1417.                                 }
  1418.  
  1419.                                     /* Make sure that the following
  1420.                                      * setup/initialization will not
  1421.                                      * touch the serial configuration.
  1422.                                      */
  1423.  
  1424.                                 memcpy(PrivateConfig -> SerialConfig,Config -> SerialConfig,sizeof(struct SerialSettings));
  1425.  
  1426.                                 ConfigSetup();
  1427.  
  1428.                                 break;
  1429.  
  1430.                                 /* Abort the dialing process. */
  1431.  
  1432.                             case GAD_ABORT:
  1433.  
  1434.                                 Terminated = TRUE;
  1435.  
  1436.                                 SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_MESSAGE],0,LocaleString(MSG_DIALPANEL_ABORTING_TXT));
  1437.  
  1438.                                 SerWrite("\r",1);
  1439.                                 WaitTime(1,0);
  1440.  
  1441.                                     /* Ignore the response of the modem. */
  1442.  
  1443.                                 HandleSerial();
  1444.  
  1445.                                 FlowInit(TRUE);
  1446.  
  1447.                                 break;
  1448.                         }
  1449.                     }
  1450.                 }
  1451.             }
  1452.  
  1453.                 /* Are we online or not? */
  1454.  
  1455. Quit:            if(!Online)
  1456.             {
  1457.                     /* Is the serial setup different? */
  1458.  
  1459.                 if(memcmp(Config -> SerialConfig,PrivateConfig -> SerialConfig,sizeof(struct SerialSettings)))
  1460.                 {
  1461.                         /* Swap the serial data. */
  1462.  
  1463.                     swmem(Config -> SerialConfig,PrivateConfig -> SerialConfig,sizeof(struct SerialSettings));
  1464.  
  1465.                         /* Set up the old serial configuration. */
  1466.  
  1467.                     if(ReconfigureSerial(PanelWindow,NULL) != RECONFIGURE_FAILURE)
  1468.                     {
  1469.                         if(ExitString[0])
  1470.                         {
  1471.                             SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_MESSAGE],0,LocaleString(MSG_DIALPANEL_SENDING_MODEM_EXIT_COMMAND_TXT));
  1472.  
  1473.                             FlowInit(TRUE);
  1474.  
  1475.                             SerialCommand(ExitBuffer);
  1476.  
  1477.                             WaitTime(1,0);
  1478.  
  1479.                             HandleSerial();
  1480.  
  1481.                             if(FlowInfo . Changed && FlowInfo . Error)
  1482.                             {
  1483.                                 SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_MESSAGE],0,LocaleString(MSG_DIALPANEL_ERROR_SENDING_MODEM_COMMAND_TXT));
  1484.  
  1485.                                 GotError = TRUE;
  1486.                             }
  1487.                         }
  1488.  
  1489.                         if(Config -> ModemConfig -> ModemInit[0] && !GotError)
  1490.                         {
  1491.                             SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_MESSAGE],0,LocaleString(MSG_DIALPANEL_SENDING_MODEM_INIT_COMMAND_TXT));
  1492.  
  1493.                             FlowInit(TRUE);
  1494.  
  1495.                             SerialCommand(Config -> ModemConfig -> ModemInit);
  1496.  
  1497.                             WaitTime(1,0);
  1498.  
  1499.                             HandleSerial();
  1500.  
  1501.                             if(FlowInfo . Changed && FlowInfo . Error)
  1502.                             {
  1503.                                 SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_MESSAGE],0,LocaleString(MSG_DIALPANEL_ERROR_SENDING_MODEM_COMMAND_TXT));
  1504.  
  1505.                                 GotError = TRUE;
  1506.                             }
  1507.                         }
  1508.                     }
  1509.                 }
  1510.             }
  1511.  
  1512.             if(GotError)
  1513.             {
  1514.                 WORD i;
  1515.  
  1516.                 for(i = GAD_SKIP ; i <= GAD_REMOVE ; i++)
  1517.                 {
  1518.                     GT_SetGadgetAttrs(GadgetArray[i],PanelWindow,NULL,
  1519.                         GA_Disabled,TRUE,
  1520.                     TAG_DONE);
  1521.                 }
  1522.  
  1523.                 WakeUp(PanelWindow,SOUND_BELL);
  1524.  
  1525.                 Terminated = FALSE;
  1526.  
  1527.                 do
  1528.                 {
  1529.                     if(Wait(PORTMASK(PanelWindow -> UserPort) | SIG_BREAK) & SIG_BREAK)
  1530.                         Terminated = TRUE;
  1531.                     else
  1532.                     {
  1533.                         while(!Terminated && (Massage = (struct IntuiMessage *)GT_GetIMsg(PanelWindow -> UserPort)))
  1534.                         {
  1535.                             IClass    = Massage -> Class;
  1536.                             Code    = Massage -> Code;
  1537.                             Gadget    = (struct Gadget *)Massage -> IAddress;
  1538.  
  1539.                             GT_ReplyIMsg(Massage);
  1540.  
  1541.                             KeySelect(GadgetArray,GAD_ABORT,Code,PanelWindow,&Gadget,&IClass,&Code);
  1542.  
  1543.                             if(IClass == IDCMP_CLOSEWINDOW || (IClass = IDCMP_GADGETDOWN && Gadget -> GadgetID == GAD_ABORT))
  1544.                                 Terminated = TRUE;
  1545.                         }
  1546.                     }
  1547.                 }
  1548.                 while(!Terminated);
  1549.             }
  1550.  
  1551.             RemoveGList(PanelWindow,GadgetList,(UWORD)-1);
  1552.  
  1553.             PopWindow();
  1554.  
  1555.             CloseWindow(PanelWindow);
  1556.         }
  1557.     }
  1558.  
  1559.     FreeGadgets(GadgetList);
  1560.  
  1561.     SZ_FreeBoxes(BoxList);
  1562.  
  1563.             /* Reset the scanner. */
  1564.  
  1565.     FullCheck = FALSE;
  1566.  
  1567.     FlowInit(TRUE);
  1568.  
  1569.         /* We are done now, restart echoing serial */
  1570.  
  1571.     Quiet = FALSE;
  1572.  
  1573.         /* Reset the display if necessary. */
  1574.  
  1575.     if(ResetDisplay)
  1576.     {
  1577.         if(!DisplayReset())
  1578.             return(FALSE);
  1579.     }
  1580.  
  1581.     if(Online)
  1582.     {
  1583.         SetDialMenu(FALSE);
  1584.  
  1585.             /* Send the startup macro if necessary. */
  1586.  
  1587.         if(SendStartup)
  1588.         {
  1589.             if(Config -> CommandConfig -> StartupMacro[0])
  1590.                 SerialCommand(Config -> CommandConfig -> StartupMacro);
  1591.  
  1592.             SendStartup = FALSE;
  1593.         }
  1594.     }
  1595.  
  1596.     return(Result);
  1597. }
  1598.